package com.leonardo.persistenceme.metadatahandlers;

import java.util.Hashtable;

public class MetadataRepository {

	public Hashtable containers = new Hashtable();
	public static MetadataRepository instance;
	
	public static MetadataRepository getInstace() {
		if(instance == null)
			instance = new MetadataRepository();
		return instance;
	}
	
	private MetadataRepository() { 
		configure();
	}
	
	private void configure() {
		try {
			containers = PersistenceMetadataReader.getMetadataReader().getMetadataContainers();
		} catch (Exception e) {
			e.printStackTrace();
			{/*System.out.println("No configuration");*/}
		}
	}
	
	public PersistenceMetadataContainer getContainer(String id) {
		if(!containers.containsKey(id))
			throw new IllegalArgumentException("No container found with id " + id);
		return (PersistenceMetadataContainer) containers.get(id);
	}
}
